Skip to content

fix: add base field to xt_option_entry for libxtables >= 1.8.11 - #1

Open
zn-yonib98 wants to merge 1 commit into
masterfrom
fix/xt_option_entry-base-libxtables-1811
Open

fix: add base field to xt_option_entry for libxtables >= 1.8.11#1
zn-yonib98 wants to merge 1 commit into
masterfrom
fix/xt_option_entry-base-libxtables-1811

Conversation

@zn-yonib98

@zn-yonib98 zn-yonib98 commented Jul 29, 2026

Copy link
Copy Markdown

Problem

iptables 1.8.11 appended a field to struct xt_option_entry (changelog: "Introduce struct xt_option_entry::base"):

unsigned int min, max;        /* <= 1.8.10 */
unsigned int min, max, base;  /* >= 1.8.11 */

On 64-bit this grows sizeof(struct xt_option_entry) from 48 to 56 bytes. iptc/xtables.py still declares the pre-1.8.11 layout, so _option_lookup() walks each extension's x6_options table with an 8-byte-short stride and reads every option after the first at the wrong offset. Setting --dports on a multiport match then fails with no such parameter.

Note: the libxtables soname/libtool version was not bumped for this change (libxtables.so.12.7.0 is byte-identical on 1.8.9 and 1.8.11), so the layout change is only visible via the iptables release version.

Fix

Append ("base", ct.c_uint) to xt_option_entry so the ctypes layout matches libxtables >= 1.8.11. Version bumped to 1.2.0.1.

Verification

Built for py2.7 and py3.11; tested on Debian trixie (real iptables v1.8.11):

sizeof(xt_option_entry) = 56
multiport dports set OK -> 8888

@zn-yonib98
zn-yonib98 force-pushed the fix/xt_option_entry-base-libxtables-1811 branch from ece198c to 190104a Compare July 29, 2026 11:09
Comment thread iptc/version.py Outdated

__pkgname__ = "python-iptables"
__version__ = "1.2.0"
__version__ = "1.2.0.post1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.1

iptables 1.8.11 appended `base` to struct xt_option_entry (48 -> 56 bytes), so
the ctypes _option_lookup stride was 8 bytes short and misread options after the
first (e.g. multiport --dports). append ("base", ct.c_uint) to match, and bump
version to 1.2.0.1.
@zn-yonib98
zn-yonib98 force-pushed the fix/xt_option_entry-base-libxtables-1811 branch from 190104a to e389c31 Compare July 29, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants